package Test_2;
import java.io.*;
public class Weijiniya {
	public static void main(String[] args) throws IOException  {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		System.out.println("请输入密钥：");
		String key=br.readLine();
		System.out.println("请输入明文：");
		String mingwen=br.readLine();
		StringBuffer mingwen1=new StringBuffer("");
		
		for(int i=0;i<mingwen.length();i++) {
			char a=mingwen.charAt(i);
			if(a>='a'&&a<='z')
				mingwen1.append(a);
		}
		System.out.println("密文是："+enCode(mingwen1,key));
	}
	public static StringBuffer enCode(StringBuffer mingwen1,String key) {
		StringBuffer miwen=new StringBuffer("");
		for(int i=0;i<mingwen1.length();i++) {
			int b=mingwen1.charAt(i)-97+key.charAt(i%key.length());
			miwen.append((char)(b>=91?(b-26):b));
		}
		return miwen;
	}
}